package com.gxgeek.spring.security.validator;

import com.gxgeek.spring.security.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @author gaoxing
 * @create 2017-09-30 上午10:45
 */
public class GxConstraintValidator  implements ConstraintValidator<GxConstraint, Object> {

    @Autowired
    HelloService helloService;
    @Override
    public void initialize(GxConstraint constraintAnnotation) {
        System.out.println("my validator init");

    }

    @Override
    public boolean isValid(Object value, ConstraintValidatorContext context) {
        helloService.greeting("tom");
        System.out.println(value);
        return false;
    }
}
